﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Entities;
using DataAccess;

namespace InsuranceVehicle.AdminSite
{
    public partial class AddInsuranceType : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            EmployeeInfo emp = new EmployeeInfo();
            emp = (EmployeeInfo)Session["Employee"];
            if (emp != null)
            {
                if (emp.Department == 1)
                {
                    Menu1.ShowElement = "all";
                }
                else
                {
                    Menu1.ShowElement = "no";
                }
            }
            else
            {
                Response.Redirect("LoginAdmin.aspx");
            }
        }

        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            InsuranceTypeAccess db = new InsuranceTypeAccess();
            if (IsValid)
            {
                InsuranceTypeInfo i = new InsuranceTypeInfo();
                i.InsuranceName = txtInsuName.Text;
                i.Description = txtInsuDescription.Text;
                i.UnitPrice = float.Parse(txtUnitPrice.Text);

                Response.Write("<script>alert('" + db.InsertInsuranceType(i) + "')</script>");


            }
        }

        protected void btnReset_Click(object sender, EventArgs e)
        {
            txtInsuDescription.Text = "";
            txtInsuName.Text = "";
            txtUnitPrice.Text = "";
        }
    }
}